/**
 * Lambda表达式（）
 * @author smallcatX0 (smallcatx0@gmail.com)
 * @date    2018-01-23 14:25:40
 * @version $Id$
 */

public class Lambda  {
    public static void main(String[] args) {
		book b1[] = new book[] {
			new book("java入门经典",79.45),
			new book("python简单教程",59.00),
			new book("sql开发天书",63.45),
			new book("node.js实战",48.50)
		};
		// lambda表达式
		java.util.Arrays.sort(b1,(x,y)->{
			if (x.p > y.p) {
				return 1;
			}else if (x.p < y.p) {
				return -1;				
			}else{
				return 0;
			}
		});
		// 输出
		for (book one :b1 ) {
			System.out.print(one);
		}

	}
}

class book{
	public String t;
	public double p;
	public book(){}
	public book(String t,double p){
		this.t = t;
		this.p = p;
	}
	public String toString(){
		return "书名： " + this.t + "价格： "+this.p+"\n";
	}

}